<?php
require_once 'BaseController.php';

/**
 * 【SP版】店舗詳細 コントローラ
 */
class Mobileapi_ShopdetailController extends Mobileapi_BaseController
{

    /**
     * メインアクション
     */
    public function indexAction()
    {
        $params = $this->getParameters();
        $code = $params['Code'];
        $typ = $params['Map'];

        $this->makeTemplateParams($code);

        if ($typ == 'map')
        {
            $this->displayBody2('map');
        }
        else
        {
            $this->displayBody2('index');
        }
    }

    private function makeTemplateParams($code)
    {
        $model = new Shop_Model_Detail();
        $model_staff = new Mobileapi_Model_TenpoStaff();
        $shop_tatemono = new Mobileapi_Model_BukkenTenpo();
        $rstdtl_model = new Rstdtl_Model_Bukendtl();

        $params = array();
        $params['ShopCd'] = $code;

        $data = $model->getList($params);
        $data = $model->convertData($data);

        $apalogurl = $this->_config['apm']['apl']['apalog']['baseurl'];
        $tenpoimageurl = $this->_config['apm']['apl']['imagesvurl'] . 'fs/tenpoimg/';
        $data = $model->convertData($data[0], $apalogurl, $tenpoimageurl);
        // CALLNOTE対応暫定固定で記述
        if (!empty($data['CONNECTION_NO']))
        {
            $data['CONNECTION_NO'] = substr($data['CONNECTION_NO'], 0, 4) . '12';
        }

        // Callクレヨン対応
        $callCrayonNumber = $model->getCallCrayonNumber($this->_config['callcrayons']['api'], $this->_config['callcrayons']['service_id'], $code, '36');
        $data['CALL_CRAYON_NO'] = $callCrayonNumber;
        /*
         * if (! empty ( $data ['CALL_CRAYON_NO'] )) { // フリー番号ではない・・・ $data ['hasFreeTel'] = false;
         * $data ['IS_FREE_CALL'] = false; }
         */

        $this->_data['shop'] = $data;

        $this->_data['tatemono'] = $shop_tatemono->getTatemonoListByTenpoCD($code);

        $staff_data = $model_staff->getStaffComment($code);
        $staff_data = $model_staff->convertStaffComment($staff_data);
        $this->_data['staff'] = $staff_data['STAFF'];

        // PV増分処理
        $rstdtl_model->S_RegPageViewLog($this->_data['shop']['M05_TENPO_CD'], 1, 95, "NULL", 1);
    }

}
?>
